﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

public partial class MemberImage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string memberId = Request["memberId"];
        if (String.IsNullOrEmpty(memberId))
        {
            return;
        }

        // load the image
        BadHabit.Factory.Data.TeamDataSet team = new BadHabit.Factory.Data.TeamDataSet();
        BadHabit.Factory.Data.TeamDataSetTableAdapters.MemberAvatarTableAdapter memberAvatarTA = new BadHabit.Factory.Data.TeamDataSetTableAdapters.MemberAvatarTableAdapter();
        memberAvatarTA.FillByMemberId(team.MemberAvatar, memberId);

        if (team.MemberAvatar.Rows.Count == 0)
        {
            return;
        }

        // and return it as a PNG file
        Response.ContentType = "image/png";
        Response.BinaryWrite(team.MemberAvatar[0].MemberImage);
    }
}
